package viewdatabase;

import general.art.*;
import general.guicontrols.clusterpanels.ClusterDisplay;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

/**
*
* @author tom3
*
*/
public class ClusterGUI {

		/**
		 *
		 */
		private final static int PREFREDED_WIDTH = 1200;

		/**
		 * 
		 */
		private final static int PREFREDED_HIEGHT = 900;

		/**
		 *
		 */
		private JFrame mFrame;

		private ClusterGUI(final int seedNode, final int depth) {

			mFrame = new JFrame();
			
			mFrame.setSize( new Dimension(PREFREDED_WIDTH, PREFREDED_HIEGHT));
			
			
			
			
			
			try{
				mFrame.setTitle("Seed Node: " + Node.FIND_NODE(seedNode).toString()  + ", Cluster Depth: " + depth);
				CenteredCluster myCenteredCluster = new CenteredCluster(seedNode, depth);
				final ClusterDisplay myDisplay  =  new ClusterDisplay(myCenteredCluster);
				mFrame.add(myDisplay );

				
				JPanel p = new JPanel();
				p.setPreferredSize( new Dimension(100, 40));
				
				JButton up = new JButton("Up");
				up.addMouseListener( new MouseAdapter(){

					@Override
					public void mouseClicked(MouseEvent arg0) {
						
						
						myDisplay.addYOffSet( -50);
						
					}
			
				
				});
				p.add( new JButton("Up"));
				p.add( new JButton("Down"));
				p.add( new JButton("Left"));
				p.add( new JButton("Right"));
				
				p.add( new JButton("Zoom in"));
				p.add( new JButton("Zoom out"));
				p.setBackground(Color.GRAY);
				mFrame.add(p, BorderLayout.NORTH);
				
				
			}catch(Exception ex){

				mFrame.add(new JLabel(ex.toString()));

			}

			
			
			mFrame.pack();
			mFrame.setVisible(true);
			mFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		}

		/**
		 *@return is the Interface that the projects runs on
		 */
		public static void createInterFace(final int seedNode , final int depth){

			SwingUtilities.invokeLater(new Runnable(){

				public void run(){

					new ClusterGUI(seedNode, depth);

				}

			});

			//return new MyInterface();
		}

		/**
		 * @param args the parameter arguments is the arguments that program gets on start up
		 */
		public static void main(final String [] args){
			
			createInterFace(34065, 2);
			
		}

	}
